package com.huike.web.controller.report;


import com.huike.common.core.domain.AjaxResult;
import com.huike.common.utils.DateUtils;
import com.huike.common.utils.SecurityUtils;
import com.huike.report.service.IReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;


    /**
     * 首页--基础数据统计
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime,endCreateTime));
    }


    /*
    线索数量、商机数量、合同数量、最终成交的合同金额
     */
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo(){
        return AjaxResult.success(reportService.getTodayInfo(SecurityUtils.getUsername(), DateUtils.getDate()));
    }


    //查询当前用户**待根进**的线索，商机，和**待分配**的线索和商机
    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(String beginCreateTime ,String endCreateTime 	){
        return AjaxResult.success(reportService.getTodoInfo(beginCreateTime, endCreateTime));
    }

    /**
     * 首页数据--商机转化龙虎榜
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/businessChangeStatistics")
    public AjaxResult businessChangeStatistics(String beginCreateTime ,String endCreateTime ){
        return AjaxResult.success(reportService.getBusinessChangeStatistics(beginCreateTime, endCreateTime));
    }

    /**
     * 首页数据--线索转化龙虎榜
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/salesStatistic")
    public AjaxResult salesStatistic(String beginCreateTime ,String endCreateTime ){
        return AjaxResult.success(reportService.getClueChangeStatistic(beginCreateTime, endCreateTime));
    }

}